package online.yysh.charging;

import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.google.android.material.tabs.TabLayout;

import online.yysh.charging.base.BaseActivity;
import online.yysh.charging.base.BaseFragment;
import online.yysh.charging.base.TabFragmentAdapter;
import online.yysh.charging.fragment.CompleteFragment;
import online.yysh.charging.fragment.IncompleteFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 接口获得的都是已完成订单，未完成订单通过判断当前用户状态获得
 */
public class OrderActivity extends BaseActivity {

    private TabLayout tabLayout;
    private ViewPager vp;
    private List<BaseFragment> fragments = new ArrayList<>();
    private TabFragmentAdapter adapter;
    private String[] titles = new String[]{"进行中", "已完成"};
    private TextView tv_title, tv_cancel;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_order;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        tv_title = findViewById(R.id.tv_title);
        tv_title.setText(R.string.my_order);
        tv_cancel = findViewById(R.id.tv_cancel);
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tabLayout = findViewById(R.id.tl);
        vp = findViewById(R.id.vp_order);
        for (String title : titles) {
            tabLayout.addTab(tabLayout.newTab().setText(title));
        }
        fragments.add(new IncompleteFragment());
        fragments.add(new CompleteFragment());
        adapter = new TabFragmentAdapter(this, fragments, titles, getSupportFragmentManager());
        vp.setAdapter(adapter);
        tabLayout.setupWithViewPager(vp);
    }

    @Override
    protected void initData() {

    }

}